<@override name="page-title">
添加文章信息
</@override>
<@override name="page-style">
<link rel="stylesheet" href="/assets/admin/css/plugins/iCheck/custom.css">
<link rel="stylesheet" href="/assets/admin/plugins/wangeditor/css/wangEditor.min.css">
<link rel="stylesheet" href="/assets/admin/css/plugins/file-upload/bootstrap-fileupload.css">
<link href="/assets/admin/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
</@override>
<@override name="page-body">

<div class="ibox-content">
    <form class="form-horizontal m-t" id="updateForm" enctype="multipart/form-data">
        <input type="hidden" name="majorType" value="${majorType}">
        <input type="hidden" name="projectId" value="${project.id?default(0)}">
        <#if minorType??>
            <input type="hidden" name="minorType" value="${minorType}">
        <#else>
            <div class="form-group">
                <label class="col-xs-3 control-label">文章类型：</label>
                <div class="col-xs-8">
                    <select class="form-control" name="minorType">
                        <#list typeList as type>
                            <option value="${type}"
                                    <#if type_index == 0>selected</#if>>${type.desc}</option>
                        </#list>
                    </select>
                </div>
            </div>
        </#if>
        <#if project??>
            <div class="form-group">
                <label class="col-xs-3 control-label">所属项目：</label>
                <div class="col-xs-8">
                    <label>${project.title}</label>
                </div>
            </div>
        </#if>
        <div class="form-group">
            <label class="col-xs-3 control-label">文章来源：</label>
            <div class="col-xs-8">
                <input type="text" class="form-control" value="" id="source" name="source" placeholder="请输入文章来源"
                       minlength="2" required="" aria-required="true">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">文章作者：</label>
            <div class="col-xs-8">
                <input type="text" class="form-control" value="" id="author" name="author" placeholder="请输入文章作者"
                       minlength="2" required="" aria-required="true">
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">发布日期：</label>
            <div class="col-xs-8">
                <div class="input-group date" id="pubdateDiv">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input type="text" class="form-control" placeholder="请输入发布时间" name="pubdate">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">新闻标题：</label>
            <div class="col-xs-8">
                <input type="text" class="form-control" value="" id="title" name="title" placeholder="请输入新闻标题"
                       minlength="2" required="" aria-required="true">
            </div>
        </div>

        <div class="form-group">
            <label class="col-xs-3 control-label">文章简介：</label>
            <div class="col-xs-8">
                <textarea class="form-control" id="summary" name="summary" rows="3"
                          placeholder="请输入文章简介"></textarea>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">文章内容：</label>
            <div class="col-xs-8">
                <script id="container" name="content" type="text/plain"></script>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">文章图片：</label>
            <div class="col-xs-8">
                <div class="fileupload fileupload-new" data-provides="fileupload">
                    <div class="btn-group">
                        <label title="上传图片" for="fileupload" class="btn btn-primary">
                            <input type="file" accept="image/*" name="file" id="fileupload" class="hide">上传图片
                        </label>
                    </div>
                    <div class="fileupload-new thumbnail" style="width: 200px; height: 150px;">
                        <img src="/assets/admin/img/noimage.jpg" alt="">
                    </div>
                    <div class="fileupload-preview fileupload-exists thumbnail" id="imgDiv"
                         style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-xs-3 control-label">首页展示：</label>
            <div class="col-xs-8">
                <div class="checkbox-inline i-checks">
                    <label><input type="radio" value="1" name="displayHome"> <i></i> 是</label>
                    <label><input type="radio" value="0" checked="" name="displayHome"> <i></i> 否</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">二级页展示：</label>
            <div class="col-xs-8">
                <div class="checkbox-inline i-checks">
                    <label><input type="radio" value="1" name="displayDetail"> <i></i> 是</label>
                    <label><input type="radio" value="0" checked="" name="displayDetail"> <i></i> 否</label>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-xs-3 control-label">浏览权限：</label>
            <div class="col-xs-8">
                <div class="checkbox-inline i-checks">
                    <label><input type="radio" value="VISITOR" checked="" name="privilegeLevel"> <i></i> 游客</label>
                    <label><input type="radio" value="NORM" name="privilegeLevel"> <i></i> 普通用户</label>
                    <label><input type="radio" value="VIP" name="privilegeLevel"> <i></i> VIP用户</label>
                </div>
            </div>
        </div>

        <div class="form-group">
            <label class="col-xs-3 control-label">浏览次数：</label>
            <div class="col-xs-8">
                <input type="number" class="form-control" value="" id="readCount" name="readCount"
                       placeholder="请输入浏览次数" min="0"
                       minlength="1" required="">
            </div>
        </div>


        <div class="form-group">
            <label class="col-xs-3 control-label">展示顺序：</label>
            <div class="col-xs-8">
                <input type="number" class="form-control" value="100" id="displayOrder" name="displayOrder"
                       placeholder="请输入文章展示顺序(按从小到大排序)" min="0"
                       minlength="1" required="">
            </div>
        </div>

        <div class="form-group">
            <div class="col-xs-12 col-xs-offset-4">
                <button class="btn btn-primary" type="submit">保存</button>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <button onClick="layer_close();" class="btn btn-default radius" type="button">
                    取消
                </button>
            </div>
        </div>
    </form>
</div>
</@override>
<@override name="page-script">
<script type="text/javascript" src="/assets/admin/js/plugins/iCheck/icheck.min.js"></script>
<script type="text/javascript" src="/assets/admin/js/plugins/validate/jquery.validate.min.js"></script>
<script type="text/javascript" src="/assets/admin/js/plugins/validate/messages_zh.min.js"></script>
<script src="/assets/admin/js/plugins/file-upload/bootstrap-fileupload.js"></script>
<script src="/assets/admin/js/plugins/jquery-form/jquery.form.js"></script>
<script src="/assets/admin/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="/assets/admin/plugins/ueditor/ueditor.config.js"></script>
<script src="/assets/admin/plugins/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("#pubdateDiv").datepicker({
            autoclose: !0,
            clearBtn: true,
            todayHighlight: true
        });
        var ue = UE.getEditor('container');

        $("#updateForm").validate({
            submitHandler: function (form) {
                var index = parent.layer.getFrameIndex(window.name);
                $(form).ajaxSubmit({
                    url: "/admin/article/save.json",
                    type: "POST",
                    success: function (data) {
                        if (data.ret) {
                            parent.$("#layer-data").val('1');
                        } else {
                            parent.$("#layer-data").val(data.errmsg);
                        }
                        parent.layer.close(index);
                    }
                });
            }
        })
    })
    ;
</script>
</@override>
<@extends name="admin/common/common.ftl"/>